<template>
    <div>
        <van-nav-bar title="This实例创建" fixed placeholder left-arrow @click-left="onClickLeft" />
        <van-button type="primary" size="mini" @click="openToast">click me</van-button>
        <Son ref="sonRef"></Son>

    </div>
</template>

<script setup lang="ts">
import { ref, getCurrentInstance } from 'vue';
import Son from '../components/son.vue'
const proxy:any = getCurrentInstance()?.proxy 

const onClickLeft = () => history.back()
const openToast = ()=>{
    //?表示可能为空,解决ts可能的类型错误
    // proxy.$refs?.sonRef?.open()相当于
    // const sonRef = ref<any>(null)
    proxy.$refs?.sonRef?.open()
}

</script>

<style scoped lang="scss"></style>